{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-07-30T14:12:12.573644Z",
     "start_time": "2019-07-30T14:12:10.081921Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Found 17 runs in path ./robust03/runs/\n"
     ]
    }
   ],
   "source": [
    "from trectools import misc, TrecRun, TrecQrel, procedures\n",
    "\n",
    "qrels_file = \"./robust03/qrel/robust03_qrels.txt\"\n",
    "path_to_runs = \"./robust03/runs/\"\n",
    "\n",
    "qrels = TrecQrel(qrels_file)\n",
    "\n",
    "runs = procedures.list_of_runs_from_path(path_to_runs, \"*.gz\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-07-30T14:13:32.029195Z",
     "start_time": "2019-07-30T14:12:12.575418Z"
    }
   },
   "outputs": [],
   "source": [
    "# Run all evaluation metrics to all available runs\n",
    "results = procedures.evaluate_runs(runs, qrels, per_query=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-07-30T14:13:32.085336Z",
     "start_time": "2019-07-30T14:13:32.030821Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "KendalltauResult(correlation=0.764705882352941, pvalue=2.0270077800034225e-06)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# check the system correlation between P@10 and MAP using Kendall's tau for all systems participating in a campaign\n",
    "misc.get_correlation( misc.sort_systems_by(results, \"P_10\"),\n",
    "                      misc.sort_systems_by(results, \"map\"), correlation = \"kendall\") # Correlation: 0.7647\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-07-30T14:13:32.134002Z",
     "start_time": "2019-07-30T14:13:32.086473Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(0.7741300366300368, -1)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# check the system correlation between P@10 and MAP using Tau's ap for all systems participating in a campaign\n",
    "misc.get_correlation( misc.sort_systems_by(results, \"P_10\"),\n",
    "                      misc.sort_systems_by(results, \"map\"), correlation = \"tauap\") # Correlation: 0.77413\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "latex_envs": {
   "LaTeX_envs_menu_present": true,
   "autoclose": false,
   "autocomplete": true,
   "bibliofile": "biblio.bib",
   "cite_by": "apalike",
   "current_citInitial": 1,
   "eqLabelWithNumbers": true,
   "eqNumInitial": 1,
   "hotkeys": {
    "equation": "Ctrl-E",
    "itemize": "Ctrl-I"
   },
   "labels_anchors": false,
   "latex_user_defs": false,
   "report_style_numbering": false,
   "user_envs_cfg": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
